public class Solution {
    public String addStrings(String num1, String num2) {
        StringBuilder s = new StringBuilder();
        int carry = 0, i = num1.length()-1, j = num2.length()-1;
        while(i >= 0 || j >= 0 || carry != 0){
            if(i >= 0) {
                carry += num1.charAt(i--)-'0';
            }
            if(j >= 0) {
                carry += num2.charAt(j--)-'0';
            }
            s.append(carry % 10);
            carry /= 10;
        }
        return s.reverse().toString();
    }

    public int firstUniqueChar(String s){
        int[] count = new int[26];
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            count[ch-'a']++;
        }
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (count[ch-'a'] == 1){
                return i;
            }
        }
        return -1;
    }

    public boolean isNumberOrChar(char ch){
        if (ch >= '0' && ch <= '9' || ch >= 'a' && ch <= 'z'){
            return true;
        }else {
            return false;
        }
    }

    public boolean isPalindrome(String s){
        s = s.toLowerCase();
        int i = 0;
        int j = s.length()-1;
        while (i < j){
            while (i < j && !isNumberOrChar(s.charAt(i))){
                i++;
            }
            while (i < j && !isNumberOrChar(s.charAt(j))){
                j--;
            }
            if (s.charAt(i) == s.charAt(j)){
                i++;
                j--;
            }else {
                return false;
            }
        }
        return true;
    }
}


